.class public Lcom/glympse/platform/common/PlaceList;
.super Ljava/lang/Object;
.source "PlaceList.java"


# static fields
.field private static final FILE_NAME:Ljava/lang/String; = "places"


# instance fields
.field public m_listPlaces:Lcom/glympse/platform/GVector$Places;


# direct methods
.method public constructor <init>()V
    .locals 1

    .prologue
    .line 19
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 23
    new-instance v0, Lcom/glympse/platform/GVector$Places;

    invoke-direct {v0}, Lcom/glympse/platform/GVector$Places;-><init>()V

    iput-object v0, p0, Lcom/glympse/platform/common/PlaceList;->m_listPlaces:Lcom/glympse/platform/GVector$Places;

    .line 19
    return-void
.end method

.method private Save()V
    .locals 5

    .prologue
    .line 104
    new-instance v1, Lcom/glympse/platform/GFile;

    invoke-direct {v1}, Lcom/glympse/platform/GFile;-><init>()V

    .line 105
    .local v1, oGFile:Lcom/glympse/platform/GFile;
    const-string v4, "places"

    invoke-virtual {v1, v4}, Lcom/glympse/platform/GFile;->OpenForOutput(Ljava/lang/String;)Z

    move-result v4

    if-nez v4, :cond_0

    .line 125
    :goto_0
    return-void

    .line 110
    :cond_0
    new-instance v3, Ljava/lang/StringBuffer;

    invoke-direct {v3}, Ljava/lang/StringBuffer;-><init>()V

    .line 112
    .local v3, strbuf:Ljava/lang/StringBuffer;
    iget-object v4, p0, Lcom/glympse/platform/common/PlaceList;->m_listPlaces:Lcom/glympse/platform/GVector$Places;

    invoke-virtual {v4}, Lcom/glympse/platform/GVector$Places;->elements()Ljava/util/Enumeration;

    move-result-object v0

    .local v0, iterPlace:Ljava/util/Enumeration;
    :goto_1
    invoke-interface {v0}, Ljava/util/Enumeration;->hasMoreElements()Z

    move-result v4

    if-nez v4, :cond_1

    .line 124
    invoke-virtual {v1}, Lcom/glympse/platform/GFile;->Close()V

    goto :goto_0

    .line 114
    :cond_1
    invoke-interface {v0}, Ljava/util/Enumeration;->nextElement()Ljava/lang/Object;

    move-result-object v2

    check-cast v2, Lcom/glympse/platform/common/Place;

    .line 117
    .local v2, oPlaceCur:Lcom/glympse/platform/common/Place;
    const/4 v4, 0x0

    invoke-virtual {v3, v4}, Ljava/lang/StringBuffer;->setLength(I)V

    .line 118
    invoke-virtual {v2, v3}, Lcom/glympse/platform/common/Place;->Serialize(Ljava/lang/StringBuffer;)V

    .line 121
    invoke-virtual {v3}, Ljava/lang/StringBuffer;->toString()Ljava/lang/String;

    move-result-object v4

    invoke-virtual {v1, v4}, Lcom/glympse/platform/GFile;->WriteLine(Ljava/lang/String;)Z

    goto :goto_1
.end method


# virtual methods
.method public Add(Lcom/glympse/platform/common/Place;)V
    .locals 4
    .parameter "oPlace"

    .prologue
    .line 42
    iget-object v1, p1, Lcom/glympse/platform/common/Place;->m_strName:Ljava/lang/String;

    invoke-virtual {p0, v1}, Lcom/glympse/platform/common/PlaceList;->Find(Ljava/lang/String;)Lcom/glympse/platform/common/Place;

    move-result-object v0

    .line 43
    .local v0, oPlaceFound:Lcom/glympse/platform/common/Place;
    if-eqz v0, :cond_0

    .line 45
    iget-object v1, p0, Lcom/glympse/platform/common/PlaceList;->m_listPlaces:Lcom/glympse/platform/GVector$Places;

    invoke-virtual {v1, v0}, Lcom/glympse/platform/GVector$Places;->removeElement(Ljava/lang/Object;)Z

    .line 49
    :cond_0
    iget-object v1, p0, Lcom/glympse/platform/common/PlaceList;->m_listPlaces:Lcom/glympse/platform/GVector$Places;

    new-instance v2, Lcom/glympse/platform/common/Place;

    invoke-direct {v2, p1}, Lcom/glympse/platform/common/Place;-><init>(Lcom/glympse/platform/common/Place;)V

    const/4 v3, 0x0

    invoke-virtual {v1, v2, v3}, Lcom/glympse/platform/GVector$Places;->insertElementAt(Ljava/lang/Object;I)V

    .line 52
    invoke-direct {p0}, Lcom/glympse/platform/common/PlaceList;->Save()V

    .line 53
    return-void
.end method

.method protected Clear()V
    .locals 1

    .prologue
    .line 98
    iget-object v0, p0, Lcom/glympse/platform/common/PlaceList;->m_listPlaces:Lcom/glympse/platform/GVector$Places;

    invoke-virtual {v0}, Lcom/glympse/platform/GVector$Places;->removeAllElements()V

    .line 99
    return-void
.end method

.method public Find(Ljava/lang/String;)Lcom/glympse/platform/common/Place;
    .locals 3
    .parameter "strPlace"

    .prologue
    .line 58
    invoke-static {p1}, Lcom/glympse/platform/common/Helpers;->IsEmpty(Ljava/lang/String;)Z

    move-result v2

    if-nez v2, :cond_1

    .line 60
    iget-object v2, p0, Lcom/glympse/platform/common/PlaceList;->m_listPlaces:Lcom/glympse/platform/GVector$Places;

    invoke-virtual {v2}, Lcom/glympse/platform/GVector$Places;->elements()Ljava/util/Enumeration;

    move-result-object v0

    .local v0, iterPlace:Ljava/util/Enumeration;
    :cond_0
    invoke-interface {v0}, Ljava/util/Enumeration;->hasMoreElements()Z

    move-result v2

    if-nez v2, :cond_2

    .line 70
    .end local v0           #iterPlace:Ljava/util/Enumeration;
    :cond_1
    const/4 v2, 0x0

    :goto_0
    return-object v2

    .line 62
    .restart local v0       #iterPlace:Ljava/util/Enumeration;
    :cond_2
    invoke-interface {v0}, Ljava/util/Enumeration;->nextElement()Ljava/lang/Object;

    move-result-object v1

    check-cast v1, Lcom/glympse/platform/common/Place;

    .line 64
    .local v1, oPlaceCur:Lcom/glympse/platform/common/Place;
    iget-object v2, v1, Lcom/glympse/platform/common/Place;->m_strName:Ljava/lang/String;

    invoke-virtual {v2, p1}, Ljava/lang/String;->equalsIgnoreCase(Ljava/lang/String;)Z

    move-result v2

    if-eqz v2, :cond_0

    move-object v2, v1

    .line 66
    goto :goto_0
.end method

.method public Load()V
    .locals 4

    .prologue
    .line 131
    new-instance v1, Lcom/glympse/platform/GFile;

    invoke-direct {v1}, Lcom/glympse/platform/GFile;-><init>()V

    .line 132
    .local v1, oGFile:Lcom/glympse/platform/GFile;
    const-string v3, "places"

    invoke-virtual {v1, v3}, Lcom/glympse/platform/GFile;->OpenForInput(Ljava/lang/String;)Z

    move-result v3

    if-eqz v3, :cond_0

    .line 135
    const/4 v0, 0x0

    .line 136
    .local v0, listNameValues:Lcom/glympse/platform/GVector$NameValueNodes;,"Lcom/glympse/platform/GVector$NameValueNodes;"
    :goto_0
    invoke-virtual {v1}, Lcom/glympse/platform/GFile;->ReadLine()Lcom/glympse/platform/GVector$NameValueNodes;

    move-result-object v0

    if-nez v0, :cond_1

    .line 149
    .end local v0           #listNameValues:Lcom/glympse/platform/GVector$NameValueNodes;,"Lcom/glympse/platform/GVector$NameValueNodes;"
    :cond_0
    invoke-virtual {v1}, Lcom/glympse/platform/GFile;->Close()V

    .line 150
    return-void

    .line 139
    .restart local v0       #listNameValues:Lcom/glympse/platform/GVector$NameValueNodes;,"Lcom/glympse/platform/GVector$NameValueNodes;"
    :cond_1
    new-instance v2, Lcom/glympse/platform/common/Place;

    invoke-direct {v2}, Lcom/glympse/platform/common/Place;-><init>()V

    .line 142
    .local v2, oPlace:Lcom/glympse/platform/common/Place;
    invoke-virtual {v2, v0}, Lcom/glympse/platform/common/Place;->Parse(Lcom/glympse/platform/GVector$NameValueNodes;)V

    .line 145
    iget-object v3, p0, Lcom/glympse/platform/common/PlaceList;->m_listPlaces:Lcom/glympse/platform/GVector$Places;

    invoke-virtual {v3, v2}, Lcom/glympse/platform/GVector$Places;->addElement(Ljava/lang/Object;)V

    goto :goto_0
.end method

.method public MoveToTop(Lcom/glympse/platform/common/Place;)V
    .locals 2
    .parameter "oPlace"

    .prologue
    .line 77
    iget-object v0, p0, Lcom/glympse/platform/common/PlaceList;->m_listPlaces:Lcom/glympse/platform/GVector$Places;

    invoke-virtual {v0, p1}, Lcom/glympse/platform/GVector$Places;->removeElement(Ljava/lang/Object;)Z

    .line 78
    iget-object v0, p0, Lcom/glympse/platform/common/PlaceList;->m_listPlaces:Lcom/glympse/platform/GVector$Places;

    const/4 v1, 0x0

    invoke-virtual {v0, p1, v1}, Lcom/glympse/platform/GVector$Places;->insertElementAt(Ljava/lang/Object;I)V

    .line 81
    invoke-direct {p0}, Lcom/glympse/platform/common/PlaceList;->Save()V

    .line 82
    return-void
.end method

.method public Remove(Lcom/glympse/platform/common/Place;)V
    .locals 1
    .parameter "oPlace"

    .prologue
    .line 88
    iget-object v0, p0, Lcom/glympse/platform/common/PlaceList;->m_listPlaces:Lcom/glympse/platform/GVector$Places;

    invoke-virtual {v0, p1}, Lcom/glympse/platform/GVector$Places;->removeElement(Ljava/lang/Object;)Z

    .line 91
    invoke-direct {p0}, Lcom/glympse/platform/common/PlaceList;->Save()V

    .line 92
    return-void
.end method

.method public Start()V
    .locals 0

    .prologue
    .line 28
    invoke-virtual {p0}, Lcom/glympse/platform/common/PlaceList;->Clear()V

    .line 29
    invoke-virtual {p0}, Lcom/glympse/platform/common/PlaceList;->Load()V

    .line 30
    return-void
.end method

.method public Stop()V
    .locals 0

    .prologue
    .line 35
    invoke-virtual {p0}, Lcom/glympse/platform/common/PlaceList;->Clear()V

    .line 36
    return-void
.end method
